{# SPDX-FileCopyrightText: © 2024 Siemens AG

   SPDX-License-Identifier: FSFAP
#}
{% extends "include/base.html.twig" %}

{% block content %}
  {% set isConfigMissing = not baseURL or not exportEndpoint or not tokenConfig %}
  {% macro renderMissingConfigItem(textstring) %}
    <p>{{ textstring|trans }}</p>
  {% endmacro %}

  {% if isConfigMissing %}
    <p><b>{{ 'Warning' }}</b>{{ ': Issues detected with the configuration.'|trans }}</p>

    {% if not baseURL %}
      {{ _self.renderMissingConfigItem('BaseURL configuration for LicenseDB is missing.') }}
    {% endif %}
    {% if not exportEndpoint %}
      {{ _self.renderMissingConfigItem('Export Endpoint is missing.') }}
    {% endif %}
    {% if not tokenConfig %}
      {{ _self.renderMissingConfigItem('Auth Token for LicenseDB and OIDC Config is missing. At least one is required.') }}
    {% endif %}

    <button type="submit" class="btn btn-default" disabled>{{ 'Import'|trans }}</button>
  {% else %}
    {% if licenseDBHealth is defined and not licenseDBHealth %}
      <p><b>{{ 'Warning' }}</b>{{ ': Connection to LicenseDB was not successful. Please check the settings and try again.'|trans }}</p>
      <button type="submit" class="btn btn-default" disabled>{{ 'Import'|trans }}</button>
    {% else %}
      <p><b>{{ 'LicenseDB is ready. Press Import to Begin.'|trans }}</b></p>
      <form method="post">
        <input type="hidden" name="importFrom" value="licensedb" />
        <button type="submit" class="btn btn-default">{{ 'Import'|trans }}</button>
      </form>
    {% endif %}
  {% endif %}
{% endblock %}

